package com.sx.manage.controller.company;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.sx.manage.controller.base.MBaseController;
import com.sx.manage.service.company.MCompanyMessageWebServiceImpl;
import com.sx.manage.servlet.ViewAndModel;
import com.sx.model.manage.mybatis.form.company.MCompanyMessageInfoEntityForm;
import com.sx.model.manage.mybatis.vo.company.MCompanyMessageInfoVO;
import com.sx.model.manage.mybatis.vo.result.ResultBooleanVO;
import com.sx.model.manage.mybatis.vo.result.ResultListVO;

/**
 * 公司消息配置
 * 
 * @author Administrator
 *
 */
@Controller
@RequestMapping("/company_message")
public class MCompanyMessageController extends MBaseController {
	/*** 日志 */
	private Logger log = LoggerFactory.getLogger(this.getClass());
	// 公司临时信息 webService
	@Resource(name = "mCompanyMessageWebServiceImpl")
	private MCompanyMessageWebServiceImpl mCompanyMessageWebServiceImpl;

	public MCompanyMessageWebServiceImpl getmCompanyMessageWebServiceImpl() {
		return mCompanyMessageWebServiceImpl;
	}

	public void setmCompanyMessageWebServiceImpl(MCompanyMessageWebServiceImpl mCompanyMessageWebServiceImpl) {
		this.mCompanyMessageWebServiceImpl = mCompanyMessageWebServiceImpl;
	}

	/** 数据列表列表 */
	@RequestMapping(value = "list_view")
	public ViewAndModel list_view(MCompanyMessageInfoEntityForm form) {
		ViewAndModel modelView = new ViewAndModel(request, cache);
		modelView.setViewName("company/message/message_list");
		return modelView;
	}

	/** 添加界面跳转 */
	@RequestMapping(value = "view_add")
	public ViewAndModel view_add(MCompanyMessageInfoEntityForm form) {
		ViewAndModel modelView = new ViewAndModel(request, cache);
		modelView.setViewName("company/message/message_add");
		return modelView;
	}

	/** 信息新增 */
	@RequestMapping(value = "message_save")
	@ResponseBody
	public ResultBooleanVO message_save(MCompanyMessageInfoEntityForm form, BindingResult errors) {
		log.info("公司消息配置数据编辑form={}",form);
		String error = this.fieldValidate(form, errors);
		if (null != error) {
			return new ResultBooleanVO(false, null, error);
		}
		return mCompanyMessageWebServiceImpl.message_add(form, loginConsumer());
	}

	/** 翻页信息获取 */
	@RequestMapping(value = "page")
	@ResponseBody
	public ResultListVO<MCompanyMessageInfoVO> page(MCompanyMessageInfoEntityForm form) {
		log.info("公司消息配置翻页信息form={}",form);
		return mCompanyMessageWebServiceImpl.queryPage(form);
	}

	/** 启用 **/
	@RequestMapping(value = "enable")
	@ResponseBody
	public ResultBooleanVO enable(Long id) {
		log.info("公司消息配置启用id={}",id);
		return mCompanyMessageWebServiceImpl.enable(id, loginConsumer());
	}

	/** 禁用 **/
	@RequestMapping(value = "disable")
	@ResponseBody
	public ResultBooleanVO disable(Long id) {
		log.info("公司消息配置禁用id={}",id);
		return mCompanyMessageWebServiceImpl.disable(id, loginConsumer());
	}

} // end class